package com.gthncz;

import java.io.IOException;
import java.io.InputStreamReader;

/**
 * 僵尸进程示例
 */
public class ZombieProcessDemo {

    public static void main(String[] args) {
        InputStreamReader reader = null;
        try {
            Process process = Runtime.getRuntime().exec("/bin/sh -c ifconfig");
            reader = new InputStreamReader(process.getInputStream());
            char[] buffer = new char[1024];
            int len = -1;
            while ((len = reader.read(buffer)) != -1) {
                System.out.print(new String(buffer, 0, len));
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (reader != null) {
                    reader.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }

}
